package L4;

import java.util.Scanner;

class Point {
    private double x;
    private double y;
    Point(double x,double y){
        this.x = x;
        this.y = y;
    }
    Point(){
        this(0,0);
    }
    public double getTan(){
        return y/x;
    }
    public static double distance(Point a,Point b){
        return Math.sqrt(Math.pow(a.x-b.x,2)+Math.pow(a.y-b.y, 2));
    }
    public double getDistance() {
        return Math.sqrt(x*x+y*y);
    }
    public String toString() {
        return String.format("(%.2f,%.2f)",x,y);
    }
}

/**
 * InnerTestPointAgain
 */
class  Triangle{
    private Point[] points;
    private double a,b,c;
    Triangle(Point[] ps){
        points = ps;
        a = Point.distance(points[0], points[1]);
        b = Point.distance(points[1], points[2]);
        c = Point.distance(points[0], points[2]);
    }
    Triangle(){
        this(null);
    }
    public boolean isTri(){
        return points[0].getTan() != points[1].getTan() || points[0].getTan() != points[2].getTan();
    }
    public double getPerimeter(){
        
        return a+b+c;
    }
    public double getArea(){
        double p = (a+b+c)/2.0;
        return Math.sqrt(p*(p-a)*(p-b)*(p-c));
    }
}

public class TestPointAgain {
    public static void main(String[] args) {
        Point[] points = new Point[3];
        Triangle triangle;
        Scanner sc = new Scanner(System.in);
        System.out.println("Please enter the coordinates of p1:");
        points[0] = new Point(sc.nextDouble(), sc.nextDouble());
        System.out.println("Please enter the coordinates of p2:");
        points[1] = new Point(sc.nextDouble(), sc.nextDouble());
        System.out.println("Please enter the coordinates of p3:");
        points[2] = new Point(sc.nextDouble(), sc.nextDouble());
        sc.close();
        triangle = new Triangle(points);
        if (!triangle.isTri()){
            System.out.println("Can't form a triangle!");
            return;
        }
        System.out.printf("Perimeter=%.15f%nArea=%.16f",triangle.getPerimeter(),triangle.getArea());

    }
}
